package com.shushan.setting.bean;

import com.android.net.bean.NetBaseBean;
import com.shushan.base.Constants;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;

/**
 * @ClassName: RewardBean
 * @Desciption: //TODO
 * @author: yichaohua
 * @date: 2018-08-14
 */
public class RewardBean extends NetBaseBean {

    public int auto_progress;
    public int manual_progress;
    public int priority_completion;//优先完成智能练习开关
    public int reward_increments;//奖励递增开关
    public String num;
    public String increments_num;//奖励递增值

    private HashMap<String,ScoreTimeBean> rewardMap = new HashMap<String,ScoreTimeBean>();

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        auto_progress = jsonObject.optInt("auto_progress",1);
        manual_progress = jsonObject.optInt("manual_progress",1);
        priority_completion = jsonObject.optInt("priority_completion",0);
        reward_increments = jsonObject.optInt("reward_increments",0);
        num = jsonObject.optString("num","20");
        increments_num = jsonObject.optString("increments_num","2");

        JSONObject rewardTimeJson = jsonObject.optJSONObject("reward_time");
        if(rewardTimeJson != null){
            JSONObject json = rewardTimeJson.optJSONObject(Constants.TYPE_SYNC_EXERCISE + "");
            if(json != null){
                ScoreTimeBean scoreTimeBean = new ScoreTimeBean(json.optInt("score",0),json.optInt("time",0));
                rewardMap.put(Constants.TYPE_SYNC_EXERCISE + "",scoreTimeBean);
            }

            json = rewardTimeJson.optJSONObject(Constants.TYPE_SMART_EXERCISE + "");
            if(json != null){
                ScoreTimeBean scoreTimeBean = new ScoreTimeBean(json.optInt("score",0),json.optInt("time",0));
                rewardMap.put(Constants.TYPE_SMART_EXERCISE + "",scoreTimeBean);
            }

            json = rewardTimeJson.optJSONObject(Constants.TYPE_STRANGE_WORDS_EXERCISE + "");
            if(json != null){
                ScoreTimeBean scoreTimeBean = new ScoreTimeBean(json.optInt("score",0),json.optInt("time",0));
                rewardMap.put(Constants.TYPE_STRANGE_WORDS_EXERCISE + "",scoreTimeBean);
            }

            json = rewardTimeJson.optJSONObject(Constants.TYPE_SPEAKING_EXERCISE + "");
            if(json != null){
                ScoreTimeBean scoreTimeBean = new ScoreTimeBean(json.optInt("score",0),json.optInt("time",0));
                rewardMap.put(Constants.TYPE_SPEAKING_EXERCISE + "",scoreTimeBean);
            }

            json = rewardTimeJson.optJSONObject(Constants.TYPE_ENGLISH_WORDS_EXERCISE + "");
            if(json != null){
                ScoreTimeBean scoreTimeBean = new ScoreTimeBean(json.optInt("score",0),json.optInt("time",0));
                rewardMap.put(Constants.TYPE_ENGLISH_WORDS_EXERCISE + "",scoreTimeBean);
            }

            json = rewardTimeJson.optJSONObject(Constants.TYPE_HEARING_EXERCISE + "");
            if(json != null){
                ScoreTimeBean scoreTimeBean = new ScoreTimeBean(json.optInt("score",0),json.optInt("time",0));
                rewardMap.put(Constants.TYPE_HEARING_EXERCISE + "",scoreTimeBean);
            }

            json = rewardTimeJson.optJSONObject(Constants.TYPE_CHINESE_SECT_EXERCISE + "");
            if(json != null){
                ScoreTimeBean scoreTimeBean = new ScoreTimeBean(json.optInt("score",0),json.optInt("time",0));
                rewardMap.put(Constants.TYPE_CHINESE_SECT_EXERCISE + "",scoreTimeBean);
            }

            json = rewardTimeJson.optJSONObject(Constants.TYPE_MACH_SECT_EXERCISE + "");
            if(json != null){
                ScoreTimeBean scoreTimeBean = new ScoreTimeBean(json.optInt("score",0),json.optInt("time",0));
                rewardMap.put(Constants.TYPE_MACH_SECT_EXERCISE + "",scoreTimeBean);
            }

            json = rewardTimeJson.optJSONObject(Constants.TYPE_ENGLISH_SECT_EXERCISE + "");
            if(json != null){
                ScoreTimeBean scoreTimeBean = new ScoreTimeBean(json.optInt("score",0),json.optInt("time",0));
                rewardMap.put(Constants.TYPE_ENGLISH_SECT_EXERCISE + "",scoreTimeBean);
            }

            json = rewardTimeJson.optJSONObject(Constants.TYPE_ORAL_CALCULATE_EXERCISE + "");
            if(json != null){
                ScoreTimeBean scoreTimeBean = new ScoreTimeBean(json.optInt("time",0),json.optInt("total",0),json.optInt("num",0));
                rewardMap.put(Constants.TYPE_ORAL_CALCULATE_EXERCISE + "",scoreTimeBean);
            }
        }
    }

    public HashMap<String, ScoreTimeBean> getRewardMap() {
        return rewardMap;
    }

    public void setRewardMap(HashMap<String, ScoreTimeBean> rewardMap) {
        this.rewardMap = rewardMap;
    }
}
